<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.text.locale.Convert</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.text.locale.Convert");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461">tango.text.locale.Convert</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
Initial release: 2005<br><br>
<b>author:</b><br>John Chapman<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L29">Result</a></span>
<script>explorer.outline.addDecl('Result');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Result <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L38">opCall</a></span>
<script>explorer.outline.addDecl('opCall');</script>(char[] <span class="funcparam">target</span>); [private, static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L50">opCatAssign</a></span>
<script>explorer.outline.addDecl('opCatAssign');</script>(char[] <span class="funcparam">rhs</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L62">opCatAssign</a></span>
<script>explorer.outline.addDecl('opCatAssign');</script>(char <span class="funcparam">rhs</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L71">get</a></span>
<script>explorer.outline.addDecl('get');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L80">scratch</a></span>
<script>explorer.outline.addDecl('scratch');</script>(); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd></dl></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L172">formatDateTime</a></span>
<script>explorer.outline.addDecl('formatDateTime');</script>(char[] <span class="funcparam">output</span>, Time <span class="funcparam">dateTime</span>, char[] <span class="funcparam">format</span>, IFormatService <span class="funcparam">formatService</span> = null); [public]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Converts the value of this instance to its equivalent string representation using the specified _format and culture-specific formatting information.
 </font><br><br>
<b>Params:</b><br>
<table>
<tr><td nowrap valign="top" style="padding-right: 8px"><span class="funcparam">format</span></td><td>A _format string.</td></tr>
<tr><td nowrap valign="top" style="padding-right: 8px"><span class="funcparam">formatService</span></td><td>An IFormatService that provides culture-specific formatting information.</td></tr></table><br>
<b>Returns:</b><br>
A string representation of the value of this instance as specified by format and formatService.<br><br>
<b>Remarks:</b><br>See <a href="datetimeformat.html">Time Formatting</a> for more information about date and time formatting.<br><br>
<b>Examples:</b><br>
<pre class="d_code">

 <span class="k">import</span> <span class="i">tango</span>.<span class="i">io</span>.<span class="i">Print</span>, <span class="i">tango</span>.<span class="i">text</span>.<span class="i">locale</span>.<span class="i">Core</span>, <span class="i">tango</span>.<span class="i">time</span>.<span class="i">WallClock</span>;

 <span class="k">void</span> <span class="i">main</span>() {
   <span class="i">Culture</span> <span class="i">culture</span> = <span class="i">Culture</span>.<span class="i">current</span>;
   <span class="i">Time</span> <span class="i">now</span> = <span class="i">WallClock</span>.<span class="i">now</span>;

   <span class="i">Println</span>(<span class="sl">"Current date and time: %s"</span>, <span class="i">now</span>.<span class="i">toString</span>());
   <span class="i">Println</span>();

   <span class="lc">// Format the current date and time in a number of ways.</span>
   <span class="i">Println</span>(<span class="sl">"Culture: %s"</span>, <span class="i">culture</span>.<span class="i">englishName</span>);
   <span class="i">Println</span>();

   <span class="i">Println</span>(<span class="sl">"Short date:              %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"d"</span>));
   <span class="i">Println</span>(<span class="sl">"Long date:               %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"D"</span>));
   <span class="i">Println</span>(<span class="sl">"Short time:              %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"t"</span>));
   <span class="i">Println</span>(<span class="sl">"Long time:               %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"T"</span>));
   <span class="i">Println</span>(<span class="sl">"General date short time: %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"g"</span>));
   <span class="i">Println</span>(<span class="sl">"General date long time:  %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"G"</span>));
   <span class="i">Println</span>(<span class="sl">"Month:                   %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"M"</span>));
   <span class="i">Println</span>(<span class="sl">"RFC1123:                 %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"R"</span>));
   <span class="i">Println</span>(<span class="sl">"Sortable:                %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"s"</span>));
   <span class="i">Println</span>(<span class="sl">"Year:                    %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"Y"</span>));
   <span class="i">Println</span>();

   <span class="lc">// Display the same values using a different culture.</span>
   <span class="i">culture</span> = <span class="i">Culture</span>.<span class="i">getCulture</span>(<span class="sl">"fr-FR"</span>);
   <span class="i">Println</span>(<span class="sl">"Culture: %s"</span>, <span class="i">culture</span>.<span class="i">englishName</span>);
   <span class="i">Println</span>();

   <span class="i">Println</span>(<span class="sl">"Short date:              %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"d"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Long date:               %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"D"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Short time:              %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"t"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Long time:               %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"T"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"General date short time: %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"g"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"General date long time:  %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"G"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Month:                   %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"M"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"RFC1123:                 %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"R"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Sortable:                %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"s"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>(<span class="sl">"Year:                    %s"</span>, <span class="i">now</span>.<span class="i">toString</span>(<span class="sl">"Y"</span>, <span class="i">culture</span>));
   <span class="i">Println</span>();
 }

 <span class="lc">// Produces the following output:</span>
 <span class="lc">// Current date and time: 26/05/2006 10:04:57 AM</span>
 <span class="lc">//</span>
 <span class="lc">// Culture: English (United Kingdom)</span>
 <span class="lc">//</span>
 <span class="lc">// Short date:              26/05/2006</span>
 <span class="lc">// Long date:               26 May 2006</span>
 <span class="lc">// Short time:              10:04</span>
 <span class="lc">// Long time:               10:04:57 AM</span>
 <span class="lc">// General date short time: 26/05/2006 10:04</span>
 <span class="lc">// General date long time:  26/05/2006 10:04:57 AM</span>
 <span class="lc">// Month:                   26 May</span>
 <span class="lc">// RFC1123:                 Fri, 26 May 2006 10:04:57 GMT</span>
 <span class="lc">// Sortable:                2006-05-26T10:04:57</span>
 <span class="lc">// Year:                    May 2006</span>
 <span class="lc">//</span>
 <span class="lc">// Culture: French (France)</span>
 <span class="lc">//</span>
 <span class="lc">// Short date:              26/05/2006</span>
 <span class="lc">// Long date:               vendredi 26 mai 2006</span>
 <span class="lc">// Short time:              10:04</span>
 <span class="lc">// Long time:               10:04:57</span>
 <span class="lc">// General date short time: 26/05/2006 10:04</span>
 <span class="lc">// General date long time:  26/05/2006 10:04:57</span>
 <span class="lc">// Month:                   26 mai</span>
 <span class="lc">// RFC1123:                 ven., 26 mai 2006 10:04:57 GMT</span>
 <span class="lc">// Sortable:                2006-05-26T10:04:57</span>
 <span class="lc">// Year:                    mai 2006</span>
 
</pre><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L490">ecvt</a></span>
<script>explorer.outline.addDecl('ecvt');</script>(double <span class="funcparam">d</span>, int <span class="funcparam">digits</span>, out int <span class="funcparam">decpt</span>, out bool <span class="funcparam">sign</span>); [private, extern(C)]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L497">positiveNumberFormat</a></span>
<script>explorer.outline.addDecl('positiveNumberFormat');</script>; [package, const]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>template <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L523">charTerm</a></span>
<script>explorer.outline.addDecl('charTerm');</script>(T); [package]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L538">longToString</a></span>
<script>explorer.outline.addDecl('longToString');</script>(char[] <span class="funcparam">buffer</span>, long <span class="funcparam">value</span>, int <span class="funcparam">digits</span>, char[] <span class="funcparam">negativeSign</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L578">longToHexString</a></span>
<script>explorer.outline.addDecl('longToHexString');</script>(char[] <span class="funcparam">buffer</span>, ulong <span class="funcparam">value</span>, int <span class="funcparam">digits</span>, char <span class="funcparam">format</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L598">longToBinString</a></span>
<script>explorer.outline.addDecl('longToBinString');</script>(char[] <span class="funcparam">buffer</span>, ulong <span class="funcparam">value</span>, int <span class="funcparam">digits</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L617">parseFormatSpecifier</a></span>
<script>explorer.outline.addDecl('parseFormatSpecifier');</script>(char[] <span class="funcparam">format</span>, out int <span class="funcparam">length</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L654">formatInteger</a></span>
<script>explorer.outline.addDecl('formatInteger');</script>(char[] <span class="funcparam">output</span>, long <span class="funcparam">value</span>, char[] <span class="funcparam">format</span>, NumberFormat <span class="funcparam">nf</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>enum; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br>
</dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L758">formatGeneral</a></span>
<script>explorer.outline.addDecl('formatGeneral');</script>(inout Number <span class="funcparam">number</span>, inout Result <span class="funcparam">target</span>, int <span class="funcparam">length</span>, char <span class="funcparam">format</span>, NumberFormat <span class="funcparam">nf</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L792">formatNumber</a></span>
<script>explorer.outline.addDecl('formatNumber');</script>(inout Number <span class="funcparam">number</span>, inout Result <span class="funcparam">target</span>, int <span class="funcparam">length</span>, NumberFormat <span class="funcparam">nf</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L822">formatCurrency</a></span>
<script>explorer.outline.addDecl('formatCurrency');</script>(inout Number <span class="funcparam">number</span>, inout Result <span class="funcparam">target</span>, int <span class="funcparam">length</span>, NumberFormat <span class="funcparam">nf</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L856">formatFixed</a></span>
<script>explorer.outline.addDecl('formatFixed');</script>(inout Number <span class="funcparam">number</span>, inout Result <span class="funcparam">target</span>, int <span class="funcparam">length</span>, int[] <span class="funcparam">groupSizes</span>, char[] <span class="funcparam">decimalSeparator</span>, char[] <span class="funcparam">groupSeparator</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L954">toString</a></span>
<script>explorer.outline.addDecl('toString');</script>(inout Number <span class="funcparam">number</span>, inout Result <span class="funcparam">result</span>, char <span class="funcparam">format</span>, int <span class="funcparam">length</span>, NumberFormat <span class="funcparam">nf</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1015">Number</a></span>
<script>explorer.outline.addDecl('Number');</script>; [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Number <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1026">opCall</a></span>
<script>explorer.outline.addDecl('opCall');</script>(long <span class="funcparam">value</span>); [private, static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>Number <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1057">opCall</a></span>
<script>explorer.outline.addDecl('opCall');</script>(double <span class="funcparam">value</span>, int <span class="funcparam">precision</span>); [private, static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1092">toDouble</a></span>
<script>explorer.outline.addDecl('toDouble');</script>(out double <span class="funcparam">value</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>char[] <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1307">toStringFormat</a></span>
<script>explorer.outline.addDecl('toStringFormat');</script>(inout Result <span class="funcparam">result</span>, char[] <span class="funcparam">format</span>, NumberFormat <span class="funcparam">nf</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>void <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/text/locale/Convert.d?rev=3461#L1528">round</a></span>
<script>explorer.outline.addDecl('round');</script>(int <span class="funcparam">pos</span>); [private]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2005 John Chapman. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sun Jun  8 17:12:56 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>